<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html"; charset="utf-8" />
    <title></title>
    <link href="/js/bstable/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="/js/bstable/css/bootstrap-table.css" rel="stylesheet" type="text/css">
    <link href="/css/table.css" rel="stylesheet" type="text/css" />
    <script src="/js/vue.js"></script>
    <script src="/js/axios.min.js"></script>
    <style>
        .notice_nav a:nth-child(3){border-top-right-radius: 0;border-bottom-right-radius:0}
        .notice_nav a:nth-child(4){border-top-right-radius: 4px;border-bottom-right-radius: 4px}
    </style>
</head>
<body style="background-color: #ecf0f5;font-family: 微软雅黑;color: #475059;min-width: 1000px;overflow: auto">
<div class="notice_main" id="app">
    <script src="/js/jquery/jQuery-2.2.0.min.js"></script>
    <script src="/js/bstable/js/bootstrap.min.js"></script>
    <script src="/js/bstable/js/bootstrap-table.js"></script>
    <script src="/js/bstable/js/bootstrap-table-zh-CN.min.js"></script>
    <script src="/js/layer_v2.1/layer/layer.js"></script>

    <div class="notice_check">
        <div class="l_left">
            <input type="text" v-model="name"  name="title" class="form-control" placeholder="请输入帖子标题">
        </div>
        &nbsp;&nbsp;<button type="button" @click="queryPost()" class="btn btn-primary">查询</button>
    </div>
    <br>
    <div>
        <table class="table table-bordered  table-hover">
            <tr>
                <th type="radio">选择</th>
                <th>序号</th>
                <th width="350px;">标题</th>
                <th width="500px;">内容简述</th>
                <th>内容</th>
                <th>发布人</th>
                <th>发布时间</th>
                <th>操作</th>
            </tr>
            <tr v-for="(item,index) in postList" >
                <td><label>
                    <input type="checkbox" id="inline_checkbox1" value="true">
                </label></td>
                <td>{{index+1}}</td>
                <td>{{item.title}}</td>
                <td>{{item.summarize}}</td>
                <td> <a   @click="findContent(item.post_id)">点击查看帖子内容</a></td>
                <td>{{item.applicant_name}}</td>
                <td>{{item.release_time}}</td>
                <td> <a   @click="delPost(item.post_id)">删除</a></td>
            </tr>
        </table>
    </div>
</div>
</body>
</html>
<script>
    new Vue({
        el:"#app",
        data:{
            name:'',
            postList:[],
     applicant_name:""
        },
        methods:{
            queryPost:function(){
                _this=this
                axios.get('/invitation/list', {
                    params: {
                        title: this.name,
                    }
                })
                    .then(function (response) {
                        _this.postList=response.data;
                        //console.log(response.data);
                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            },
            delPost:function(post_id) {
                // alert(post_id)
                window.localStorage.setItem("sid", post_id);
                alert("删除成功！")
                location.href = "post_management.html"
                axios.get('/invitation/del', {
                    params: {
                        post_id: post_id
                    }
                }).then(function (response) {
                    console.log(response.data);
                })
                    .catch(function (error) {
                        console.log(error);
                    });
            },
            findContent:function(post_id) {
                // alert(post_id)
                window.localStorage.setItem("post_id", post_id);
                // window.localStorage.setItem("applicant_name", applicant_name);
                location.href = "post_m_content.html"
                axios.get('/invitation/find', {
                    params: {
                        post_id: post_id
                    }
                }).then(function (response) {
                    console.log(response.data);
                })
                    .catch(function (error) {
                        console.log(error);
                    });
            }
        },
        mounted(){
            _this = this
            //查询帖子的信息
            axios.get('/invitation/list',{
                params:{
                    title:this.name
                }
            })
                .then(function (response) {
                    _this.postList = response.data;
                    console.log(response.data);
                })
                .catch(function (error) {
                    console.log(error);
                });
        }
    })
</script>
